<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
	<h:form id="frmCadParticipante">
		<br />
		<h3 style="margin-top: 0">CADASTRO DE PARTICIPANTE PESSOA JURÍDICA</h3>
		<div align="left">

			<p:commandButton value="Novo"
				actionListener="#{participanteBean.novo}" ajax="frmCadParticipante"
				disabled="#{participanteBean.novo}" />

			<p:commandButton value="Salvar" disabled="#{participanteBean.salvar}"
				actionListener="#{participanteBean.salvarPJ}"
				ajax="frmCadParticipante" />

			<p:commandButton value="Consulta" disabled="#{participanteBean.consulta}"
				action="#{pesquisaPessoaJuridicaBean.abrirDialogo('pes')}">
				<p:ajax event="dialogReturn" listener="#{participanteBean.pessoaJuridicaSelecionado}" update="frmCadParticipante"/>
			</p:commandButton>

			<p:commandButton value="Cancelar" ajax="cadEmpresa"
				actionListener="#{participanteBean.novo}"
				disabled="#{participanteBean.novo}" />

			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:tabView style="border: 0px">
				<p:tab id="cadEmpresa" title="Informações Gerais">
					<ui:include src="/privado/participante/panel/pessoaJuridicaInformacoesGeraisPanel.xhtml" />
				</p:tab>

				<p:tab id="cadLogr" title="Lista de endereços">

					<p:commandButton value="Enderecos" type="button"
						onclick="PF('dlg2').show();"
						disabled="#{participanteBean.enderecos}" />

					<p:dialog id="enderecoPesJur" header=" Enderecos" widgetVar="dlg2"
						modal="true" height="300" width="400">

						<h:panelGrid columns="2" columnClasses="label, value">
						
						Codigo logradouro
						<p:inputText id="idLogradouro"
								value="#{participanteBean.logradouro.idEndereco}" disabled="true" />
								
						Logradouro:
						<p:inputText id="logradouro" value="#{participanteBean.logradouro.endereco}" size="40" />
								
						Complemento:
						<p:inputText id="complemento" value="#{participanteBean.logradouro.complemento}" size="40" />							
					
						Bairro:
						<p:inputText id="bairro" value="#{participanteBean.logradouro.bairro}" size="40" />
					
						Numero:
						<p:inputText id="numero" value="#{participanteBean.logradouro.numero}" size="15" />		
						
						CEP:
						<p:inputMask id="cep" value="#{participanteBean.logradouro.cep}" size="8" mask="99999999" />							
							
						Tipo Endereco:
					 	<p:selectOneMenu id="tipoLogr"
								value="#{participanteBean.tipoLogrSelecionado}">
								<f:selectItem itemLabel="Selecione tipo endereço" />
								<f:selectItem itemLabel="COMERCIAL" itemValue="COMERCIAL" />
								<f:selectItem itemLabel="RESIDENCIAL" itemValue="RESIDENCIAL" />
								<f:selectItem itemLabel="COBRANCA" itemValue="COBRANCA" />
								<f:selectItem itemLabel="ENTREGA" itemValue="ENTREGA" />
							</p:selectOneMenu>
						
						Estado:
						<p:selectOneMenu id="uf" value="#{geralBean.uf}">
								<f:selectItem itemLabel="Selecione um estado" />
								<f:selectItems value="#{geralBean.estados}" var="listaEstados"
									itemValue="#{listaEstados}"
									itemLabel="#{listaEstados.descricao}" />
								<p:ajax update="municipios" event="change"
									listener="#{geralBean.filtraEstado}" />
							</p:selectOneMenu>
					
						Município:
					 	<p:selectOneMenu id="municipios" value="#{geralBean.municipio}">
								<f:selectItem itemLabel="Selecione um municipio" />
								<f:selectItems value="#{geralBean.municipios}" var="listaMun"
									itemValue="#{listaMun}" itemLabel="#{listaMun.descricao}" />
							</p:selectOneMenu>

						</h:panelGrid>
						<h:panelGrid columns="2">
							<p:commandButton value="Incluir"
								actionListener="#{participanteBean.salvarLogr(geralBean.municipio)}"
								update="listaEndereco" />

							<p:commandButton value="Cancelar" ajax="enderecoPesJur" />
						</h:panelGrid>

					</p:dialog>
					<br />
					<br />
					<ui:include src="/privado/participante/dataTable/pessoaJuridicaGerenciaEnderecosDataTable.xhtml" />
				</p:tab>
				<p:tab id="emails" title="Cadastro de Email">
					<p:commandButton value="Emails" type="button"
						onclick="PF('dlg3').show();" disabled="#{participanteBean.email}" />
					<br />
					<br />
					<p:dialog header="Emails" widgetVar="dlg3" modal="true"
						height="100" width="400">
						<h:panelGrid columns="2">
						Email:
						<p:inputText value="#{participanteBean.emails.email}" size="50" />
						
						Padrão NF-e:
						<p:selectBooleanCheckbox value="#{participanteBean.padraoNFE}" />

							<p:commandButton id="incluirEmail" icon="ui-icon-disk"
								disabled="#{participanteBean.email}"
								actionListener="#{participanteBean.salvarEmail}"
								update="listaEmail" />
						</h:panelGrid>
					</p:dialog>
					
					<ui:include src="/privado/participante/dataTable/pessoaJuridicaEmailDataTable.xhtml" />
				</p:tab>
				<p:tab id="telefones" title="Cadastro de telefone">
					<p:commandButton value="Telefones" type="button"
						onclick="PF('dlg4').show();"
						disabled="#{participanteBean.telefone}" />
					<br />
					<br />
					<p:dialog header="Telefones" widgetVar="dlg4" modal="true"
						height="150" width="350">
						<h:panelGrid id="gridTel" columns="2">
						
						DDD:
						<p:inputMask id="dddTel" value="#{participanteBean.dddTel}" size="4" mask="99" />
						
						Telefone:
						<p:inputMask id="numTel" value="#{participanteBean.tel.numero}" size="40" mask="99999999?9" />
						
						Tipo telefone:
						<p:selectOneMenu id="tipoTelefone"
								value="#{participanteBean.tipoSelecionadoTel}">
								<f:selectItem itemLabel="Selecione tipo de telefone" />
								<f:selectItem itemLabel="COMERCIAL" itemValue="COMERCIAL" />
								<f:selectItem itemLabel="RESIDENCIAL" itemValue="RESIDENCIAL" />
								<f:selectItem itemLabel="CELULAR" itemValue="CELULAR" />
							</p:selectOneMenu>

							<p:commandButton id="incluirTelefone" icon="ui-icon-disk"
								disabled="#{participanteBean.telefone}"
								actionListener="#{participanteBean.salvarTelefone}"
								update="gridData5, gridTel" />
						</h:panelGrid>
					</p:dialog>
					<ui:include src="/privado/participante/dataTable/pessoaJuridicaTelefonesDataTable.xhtml" />
				</p:tab>
			</p:tabView>
		</div>
	</h:form>
</h:body>
</html>